package com.flyoil.petromp.ui.activity.activity_course;

import android.content.Intent;

import com.flyoil.petromp.R;
import com.flyoil.petromp.adapter.adapter_course.ItemCourseGroupAdapter;
import com.flyoil.petromp.base.BaseActivity;
import com.flyoil.petromp.entity.entity_course_list.CourseEntity;
import com.flyoil.petromp.utils.OrderUtl.OrderListUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * 流程列表
 */
public class CourseListActivity extends BaseActivity {
    private ItemCourseGroupAdapter adapter;
    private List<CourseEntity> courseEntities;

    @Override
    protected int getContentViewResId() {
        return R.layout.activity_course_list;
    }

    @Override
    protected void initViews() {
        super.initViews();
        setTextTitleName("流程列表");
        setBackOnclickListner(mContext);
        recyclerView = $(R.id.list_course_list);
        setRecyviewLayoutManager(null);
        adapter = new ItemCourseGroupAdapter(mContext);
        recyclerView.setAdapter(adapter);
    }

    @Override
    protected void initEvents() {
        super.initEvents();
        adapter.setOnChidrenItemClickLinester(new ItemCourseGroupAdapter.OnChidrenItemClickLinester() {
            @Override
            public void Onclick(int position, Object entity) {
                CourseEntity.Children children = (CourseEntity.Children) entity;
                Intent intent = new Intent(mContext, CourseCertainListActivity.class);
                intent.putExtra("title_name", children.getName());
                intent.putExtra("order_type", children.getType());
                startActivity(intent);
            }
        });
    }

    @Override
    protected void initdatas() {
        super.initdatas();
        courseEntities = new ArrayList<>();
        List<CourseEntity.Children> childrens1 = new ArrayList<>();
        childrens1.add(new CourseEntity.Children("采购计划流程列表", OrderListUtil.PLAN));
        courseEntities.add(new CourseEntity("采购计划", childrens1.get(childrens1.size()-1).getType(), childrens1));
        List<CourseEntity.Children> childrens2 = new ArrayList<>();
        childrens2.add(new CourseEntity.Children("物资采购需求列表", OrderListUtil.GOODS_DEMAND));
        childrens2.add(new CourseEntity.Children("物资采购审批列表", OrderListUtil.GOODS_APPROVE));
        childrens2.add(new CourseEntity.Children("物资采购订单列表", OrderListUtil.GOODS_ORDER));
        childrens2.add(new CourseEntity.Children("物资采购验收列表", OrderListUtil.GOODS_EXAMINE));
//        childrens2.add(new CourseEntity.Children("物资质保期验收列表", OrderListUtil.GOODS_DATE_EXAMINE));
        courseEntities.add(new CourseEntity("物资采购", childrens2.get(childrens2.size()-1).getType(), childrens2));
        List<CourseEntity.Children> childrens3 = new ArrayList<>();
        childrens3.add(new CourseEntity.Children("服务任务需求列表", OrderListUtil.SERVICE_DEMAND));
        childrens3.add(new CourseEntity.Children("服务任务审批列表", OrderListUtil.SERVICE_APPROVE));
        childrens3.add(new CourseEntity.Children("服务任务订单列表", OrderListUtil.SERVICE_ORDER));
        childrens3.add(new CourseEntity.Children("服务任务验收列表", OrderListUtil.SERVICE_EXAMINE));
        courseEntities.add(new CourseEntity("服务采购", childrens3.get(childrens3.size()-1).getType(), childrens3));
        List<CourseEntity.Children> childrens4 = new ArrayList<>();
        childrens4.add(new CourseEntity.Children("付款申请列表", OrderListUtil.FINANCE));
        courseEntities.add(new CourseEntity("财务类", childrens4.get(childrens4.size()-1).getType(), childrens4));
//        List<CourseEntity.Children> childrens5 = new ArrayList<>();
//        childrens5.add(new CourseEntity.Children("供应商档案列表", "10"));
//        childrens5.add(new CourseEntity.Children("物品与服务列表", "11"));
//        courseEntities.add(new CourseEntity("供应商", "10", childrens5));
        adapter.addBottonDatas(courseEntities);
        recyclerView.notifyDataSetChanged();
        onDataSucceed();
    }
}
